﻿using HtmlAgilityPack;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HtmlParserLib.Parsers
{
    /// <summary>
    /// 中国政府采购网
    /// </summary>
    public class CcgpGovCn : CommonHtmlParser
    {
        protected override IEnumerable<HtmlNode> SelectLinkNodes(HtmlDocument doc)
        {
            var linkedPages = doc.DocumentNode.SelectNodes("//div[@class='newslist_list']//a[@href]");
            var result=linkedPages.Reverse();
            return result;
        }

        protected override string GetOtherInfo(HtmlNode link)
        {
            var dateString = link.NextSibling.NextSibling.InnerText;
            DateTime d;
            var r = DateTime.TryParse(dateString.Trim(), out d);
            if (r)
            {
                return d.ToString("yyyy-MM-dd hh:mm:ss");
            }
            else
            {
                return dateString;
            }
        }
    }
}
